#include <QtGui/QApplication>
#include <QUrl>
#include "qmlapplicationviewer.h"

#include "MyXmppClient.h"

#include "ima/minversemousearea.h"
#include "rosterlistmodel.h"
#include "chatslistmodel.h"
#include "msglistmodel.h"
#include "accountslistmodel.h"
#include "qmlvcard.h"
#include "meegimsettings.h"
#include "smileslistmodel.h"
#include "mysmiles.h"
#include "xmppmuc.h"
#include "harmattanfeed.h"
#include "smthemelistmodel.h"

#define MEEGIM_API_NAMESPACE "meegim"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app( createApplication(argc, argv) );

    qmlRegisterType<MInverseMouseArea>("InvMA", 1, 0, "InverseMouseArea");

    qmlRegisterType<MyXmppClient>(MEEGIM_API_NAMESPACE, 1, 0, "XmppClient" );
    qmlRegisterType<MeegIMSettings>(MEEGIM_API_NAMESPACE, 1, 0, "MeegIMSettings" );
    qmlRegisterType<QMLVCard>(MEEGIM_API_NAMESPACE, 1, 0, "XmppVCard" );
    qmlRegisterType<MySmiles>(MEEGIM_API_NAMESPACE, 1, 0, "MSmiles" );
    qmlRegisterType<XmppMuc>( MEEGIM_API_NAMESPACE, 1, 0, "XmppMuc" );
    qmlRegisterType<HarmattanFeed>( MEEGIM_API_NAMESPACE, 1, 0, "MEventFeed" );

    qmlRegisterUncreatableType<RosterListModel>(MEEGIM_API_NAMESPACE, 1, 0, "Roster", "Use xmppClient.roster instead");
    qmlRegisterUncreatableType<MsgListModel>(MEEGIM_API_NAMESPACE, 1, 0, "MessagesList", "");
    qmlRegisterUncreatableType<ChatsListModel>(MEEGIM_API_NAMESPACE, 1, 0, "ChatsList", "");
    qmlRegisterUncreatableType<AccountsListModel>(MEEGIM_API_NAMESPACE, 1, 0, "AccountsList", "Use settings.accounts instead");
    qmlRegisterUncreatableType<SmilesListModel>(MEEGIM_API_NAMESPACE, 1, 0, "SmilesList", "");
    qmlRegisterUncreatableType<QXmppMucManager>(MEEGIM_API_NAMESPACE, 1, 0, "QXmppMucManager", "");
    qmlRegisterUncreatableType<SmilesThemeListModel>(MEEGIM_API_NAMESPACE, 1, 0, "SmilesThemeList", "");

    QmlApplicationViewer viewer;
    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    //viewer.setMainQmlFile(QLatin1String("qrc:/qml/main.qml"));
    viewer.setSource( QUrl(QLatin1String("qrc:/qml/main.qml")) );
    viewer.showExpanded();

    EventFilter ef;
    viewer.installEventFilter(&ef);

    return app->exec();
}

